﻿
using SmartParking.Client.Entity;
using SmartParking.Client.IBLL;
using SmartParking.Client.IDAL;

namespace SmartParking.Client.BLL
{
    public class LoginBLL : ILoginBLL
    {
        private readonly ILoginDAL _loginDAL;

        public LoginBLL(ILoginDAL loginDAL)
        {
            this._loginDAL = loginDAL;
        }
        public async Task<bool> Login(string username, string password)
        {
            var loginStr = await _loginDAL.Login(username, password);
            // 用户信息反序列化
            UserEntity userEntity = Newtonsoft.Json.JsonConvert.DeserializeObject<UserEntity>(loginStr);
            if (userEntity != null) {
                GlobalEntity.CurrentUserInfo = userEntity;
                return true;
            }
            return false;
        }
    }
}
